package cn.iocoder.yudao.module.crossborder.srm.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.srm.api.dto.ContractDTO;
import cn.iocoder.yudao.module.crossborder.srm.api.dto.PurchaseOrderDTO;
import cn.iocoder.yudao.module.crossborder.srm.api.dto.SupplierCreateReqDTO;
import cn.iocoder.yudao.module.crossborder.srm.api.dto.SupplierDTO;
import cn.iocoder.yudao.module.crossborder.srm.service.SrmService;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 供应商关系管理 API 接口实现类
 *
 * @author LHL
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class SrmApiImpl implements SrmApi {

    @Resource
    private SrmService srmService;

    @Override
    public CommonResult<SupplierDTO> getSupplier(Long id) {
        SupplierDTO supplier = srmService.getSupplier(id);
        return success(supplier);
    }

    @Override
    public CommonResult<List<SupplierDTO>> getSupplierList(List<Long> ids) {
        List<SupplierDTO> suppliers = srmService.getSupplierList(ids);
        return success(suppliers);
    }

    @Override
    public CommonResult<Long> createSupplier(SupplierCreateReqDTO createReq) {
        Long id = srmService.createSupplier(createReq);
        return success(id);
    }

    @Override
    public CommonResult<PurchaseOrderDTO> getPurchaseOrder(Long id) {
        PurchaseOrderDTO purchaseOrder = srmService.getPurchaseOrder(id);
        return success(purchaseOrder);
    }

    @Override
    public CommonResult<ContractDTO> getContract(Long id) {
        ContractDTO contract = srmService.getContract(id);
        return success(contract);
    }

    @Override
    public CommonResult<Boolean> evaluateSupplier(Long supplierId, Integer score, String comment) {
        Boolean result = srmService.evaluateSupplier(supplierId, score, comment);
        return success(result);
    }

    @Override
    public CommonResult<Boolean> certifySupplier(Long supplierId, String certificationType) {
        Boolean result = srmService.certifySupplier(supplierId, certificationType);
        return success(result);
    }

    @Override
    public CommonResult<Boolean> qualityInspect(Long purchaseOrderId, String result) {
        Boolean inspectResult = srmService.qualityInspect(purchaseOrderId, result);
        return success(inspectResult);
    }

}
